package com.longge;

import java.util.Collections;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-06-08 15:17
 */
public class TruncateSentence {

    public String truncateSentence(String s, int k) {

        String[] arr = s.split(" ");
        return Stream.of(arr).limit(k).collect(Collectors.joining(" "));
    }

}
